﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace simulate_control.Basic
{
    #region USING
    using simulate_control.Repositories;
    using simulate_control.Models;
    using simulate_control.Helpers;
    using DevComponents.DotNetBar;
    using DevComponents.DotNetBar.Controls;
    #endregion

    public partial class FrmWaypointList : Form
    {
        #region VARIABLES
        public EventHandler Handler { get; set; }
        private List<WayPoint> lst;
        private string[] lstHighlightLabelName = new string[] { };
        #endregion

        public FrmWaypointList()
        {
            InitializeComponent();
        }

        public void ProcessKeyEvent(KEY keyEvent)
        {
            switch (keyEvent)
            {
                case KEY.ENTER:
                    break;
            }
        }

        public void LoadData()
        {
            lst = WayPointRepository.SelectAll();
            lstHighlightLabelName = new string[lst.Count + 1];

            int count = 0;
            lstHighlightLabelName[count] = "[NEW?]";
            count++;

            if (lst.Count > 0)
            {
                for (int i = 0; i < lst.Count; i++)
                {
                    lstHighlightLabelName[count] = lst[i].Name;
                    count++;
                }
            }
        }

        public void InitLabels(ref GroupPanel pnlMain, string[] lstHighlightLabelName)
        {
            int firsty = 41;
            int OFFY = 24;
            for (int i = 0; i < lstHighlightLabelName.Length; i++)
            {
                var lbl = new LabelX
                {
                    Text = lstHighlightLabelName[i],
                    BackColor = System.Drawing.Color.Transparent,
                    Name = "lbl" + i,
                    TabIndex = 1,
                    Size = new System.Drawing.Size(114, 18),
                };

                switch (i % 3)
                {
                    case 0:
                        lbl.Location = new Point(29, firsty);
                        break;
                    case 1:
                        lbl.Location = new Point(159, firsty);
                        break;
                    case 2:
                        lbl.Location = new Point(293, firsty);
                        firsty += OFFY;
                        break;
                }
 
                pnlMain.Controls.Add(lbl);
            }
        }

        private void FrmWaypointList_Load(object sender, EventArgs e)
        {
            LoadData();
            InitLabels(ref pnlMain, lstHighlightLabelName);
        }
    }
}
